import java.io.*;

import semantic.Errors;
import semantic.Table;
import syntaxtree.*;
import visitor.*;
import parser.MjParser;
import parser.ParseException;
import parser.TokenMgrError;

public class Main{
	public static void main(String args[]) throws ParseException, TokenMgrError{
		Table table = null;
		try{   
			MjParser parser = new MjParser(new FileInputStream(args[0]));

			Program root = parser.Start();
			table = root.accept(new TableCreator());
			root.accept(new TypeChecker(table));
			Errors.print();
		}catch(FileNotFoundException e){
			System.err.print(e);
		}
		catch(ParseException pe){
			System.err.print(pe);
		}
	}
}
